﻿<!DOCTYPE>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	//获得本项目的地址(例如: http://localhost:8080/MyApp/)赋值给basePath变量 
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	pageContext.setAttribute("basePath", basePath);
	pageContext.setAttribute("path", path);
%>
<html>
<head>
<link rel="stylesheet" type="text/css" href="${basePath}css/style.css" />
<link rel="stylesheet" type="text/css"
	href="${basePath}css/external.min.css" />
<link rel="stylesheet" type="text/css" href="${basePath}css/popup.css" />
<script type="text/javascript" src="${basePath}js/jquery-3.2.1.js"></script>
<title>简历管理</title>
<meta content="description" name="description">
<meta content="keywords" name="keywords">
</head>

<body>
	<div id="body">
		<%@include file="../header.jsp"%>

		<div id="container">
			<%@include file="../left.jsp"%>
			<!-- end .sidebar -->
			<div class="content">
				<dl class="company_center_content">
					<dt>
						<h1>
							<em></em> 发布新职位
						</h1>
					</dt>
					<dd>

						<form action="${basePath}hr/createPosition" method="post"
							id="jobForm">
							<input type="hidden" value="" name="id">
							<table class="btm">
								<tbody>
									<tr>
										<td width="25"><span class="redstar">*</span></td>
										<td width="85">职位类别</td>
										<td><input type="text" placeholder="请输入职位类别" value=""
											name="positionType" id="positionType"></td>
									</tr>
									<tr>
										<td><span class="redstar">*</span></td>
										<td>职位名称</td>
										<td><input type="text" placeholder="请输入职位名称，如：产品经理"
											value="" name="positionName" id="positionName"></td>
									</tr>

								</tbody>
							</table>

							<table class="btm">
								<tbody>

									<tr>
										<td><span class="redstar">*</span></td>
										<td>月薪范围</td>
										<!--<h3><span>(最高月薪不能大于最低月薪的2倍)</span></h3> -->
										<td>
											<div class="salary_range">
												<div>
													<input type="text" placeholder="最低月薪" value=""
														id="salaryMin" name="salaryMin"> <span>k</span>
												</div>
												<div>
													<input type="text" placeholder="最高月薪" value=""
														id="salaryMax" name="salaryMax"> <span>k</span>
												</div>
												<span>只能输入整数，如：9</span>
											</div>
										</td>
									</tr>
									<tr>
										<td><span class="redstar">*</span></td>
										<td>工作城市</td>
										<td><input type="text" placeholder="请输入工作城市，如：北京"
											value="" name="workCity" id="workCity"></td>
									</tr>
								</tbody>
							</table>

							<table class="btm">
								<tbody>
									<tr>
										<td width="25"><span class="redstar">*</span></td>
										<td width="85">工作经验</td>
										<td><input type="text" placeholder="请输入工作经验要求" value=""
											name="experience" id="experience"></td>
									</tr>
									<tr>
										<td><span class="redstar">*</span></td>
										<td>学历要求</td>
										<!--<h3><span>(最高月薪不能大于最低月薪的2倍)</span></h3> -->
										<td><input type="text" placeholder="请输入学历要求" value=""
											name="education" id="education"></td>
									</tr>
								</tbody>
							</table>

							<table class="btm">
								<tbody>
									<tr>
										<td width="25"><span class="redstar">*</span></td>
										<td width="85">职位诱惑</td>
										<td><input type="text"
											placeholder="20字描述该职位的吸引力，如：福利待遇、发展前景等" value=""
											name="benefits" class="input_520" id="benefits"></td>
									</tr>
									<tr>
										<td><span class="redstar">*</span></td>
										<td>职位描述</td>
										<td><textarea name="positionDetail" id="positionDetail"
												class="tinymce" aria-hidden="true"></textarea></td>
									</tr>
									<tr>
										<td><span class="redstar">*</span></td>
										<td>工作地址</td>
										<td><input type="text" placeholder="请输入详细的工作地址" value=""
											name="workAddress" class="input_520" id="workAddress">
										</td>
									</tr>
								</tbody>
							</table>

							<table>
								<tbody>

									<tr>
										<td width="25"></td>
										<td colspan="2">
											<!-- <input type="button" value="发布" id="formSubmit" class="btn_32"> -->
											<a href="javascript:check();" title="发布" class="btn_32">发布</a>
										</td>
									</tr>
								</tbody>
							</table>
						</form>
					</dd>
				</dl>
			</div>
			<!-- end .content -->
</body>
<script type="text/javascript">
	function check() {
		var positionType = $('#positionType').val();
		var positionName = $('#positionName').val();
		var salaryMin = $('#salaryMin').val();
		var salaryMax = $('#salaryMax').val();
		var workCity = $('#workCity').val();
		var experience = $('#experience').val();
		var education = $('#education').val();
		var benefits = $('#benefits').val();
		var positionDetail = $('#positionDetail').val();
		var workAddress = $('#workAddress').val();

		if (positionType == "" || positionType == undefined) {
			alert("请输入职位类别");
			return;
		}
		if (positionName == "" || positionName == undefined) {
			alert("请输入职位名称");
			return;
		}
		if (salaryMin == "" || salaryMin == undefined) {
			alert("请输入最低月薪");
			return;
		}
		if (salaryMax == "" || salaryMax == undefined) {
			alert("请输入最高月薪");
			return;
		}
		if (workCity == "" || workCity == undefined) {
			alert("请输入工作城市");
			return;
		}
		if (experience == "" || experience == undefined) {
			alert("请输入工作经验要求");
			return;
		}
		if (education == "" || education == undefined) {
			alert("请输入学历要求");
			return;
		}
		if (benefits == "" || benefits == undefined) {
			alert("请输入公司福利");
			return;
		}
		if (positionDetail == "" || positionDetail == undefined) {
			alert("请输入职位描述");
			return;
		}
		if (workAddress == "" || workAddress == undefined) {
			alert("请输入工作地点");
			return;
		}

		$.ajax({
			type : 'POST',
			data : {
				positionType : positionType,
				positionName : positionName,
				salaryMin : salaryMin,
				salaryMax : salaryMax,
				workCity : workCity,
				experience : experience,
				education : education,
				benefits : benefits,
				positionDetail : positionDetail,
				workAddress : workAddress
			},
			url : '${basePath}hr/createPosition',
			dataType : 'json',
			success : function(result) {
				console.log("success");
				var model = result.model;
				if (model.code == 0) {
					console.log(model.msg);
					window.location.href = "${basePath}" + model.href;
				} else {
					alert(model.msg);
					console.log(model.msg);
				}
			}
		});

	}
</script>
</html>